<template>
  <div>
    <!-- 面包屑 -->
    <el-breadcrumb separator="/" class="mb">
      <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>
        <a>数据统计</a>
      </el-breadcrumb-item>
      <el-breadcrumb-item>数据报表</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card>
      <div ref="box" style="width:100%;height:500px"></div>
    </el-card>
  </div>
</template>

<script>
import * as echarts from "echarts";
export default {
  data() {
    return {
      options: {
        title: {
          text: "用户来源"
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#E9EEF3"
            }
          }
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true
        },
        xAxis: [
          {
            boundaryGap: false
          }
        ],
        yAxis: [
          {
            type: "value"
          }
        ]
      }
    };
  },
  methods: {
    async list() {
      let myChart = echarts.init(this.$refs.box);
      let tion = await this.$axios.get("reports/type/1");
      let optionData = { ...this.options, ...tion.data.data };
      myChart.setOption(optionData);
    }
  },
  mounted() {
    this.list();
  }
};
</script>

<style lang="scss" scoped>
.mb {
  margin-bottom: 20px;
}
</style>